|
1
|
|
|
var assert = require('chai').assert, |
|
2
|
|
|
GedcomX = require('../'); |
|
3
|
|
|
|
|
4
|
|
|
describe('ExtensibleData', function(){ |
|
5
|
|
|
|
|
6
|
|
|
it('Create plain', function(){ |
|
7
|
|
|
var newEd = new GedcomX.ExtensibleData(), |
|
8
|
|
|
ed = GedcomX.ExtensibleData(); |
|
9
|
|
|
assert.instanceOf(newEd, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor with new.'); |
|
10
|
|
|
assert.instanceOf(ed, GedcomX.ExtensibleData, 'An instance of ExtensibleData is not returned when calling the constructor without new.'); |
|
11
|
|
|
}); |
|
12
|
|
|
|
|
13
|
|
|
it('Create with JSON', function(){ |
|
14
|
|
|
var ed = GedcomX.ExtensibleData({ id: 'edid' }); |
|
15
|
|
|
assert.equal(ed.getId(), 'edid', 'ID not saved properly when created with JSON'); |
|
16
|
|
|
}); |
|
17
|
|
|
|
|
18
|
|
|
it('Change ID', function(){ |
|
19
|
|
|
var ed = GedcomX.ExtensibleData({ id: 'edid' }); |
|
20
|
|
|
ed.setId('newId'); |
|
21
|
|
|
assert.equal(ed.getId(), 'newId', 'ID not saved properly when changed with setId()'); |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
|
it('toJSON()', function(){ |
|
25
|
|
|
var ed = GedcomX.ExtensibleData({ id: 'firstId' }); |
|
26
|
|
|
ed.setId('newId'); |
|
27
|
|
|
assert.deepEqual(ed.toJSON(), {id:'newId'}, 'JSON export is incorrect'); |
|
28
|
|
|
}); |
|
29
|
|
|
|
|
30
|
|
|
it('constructor does not copy instances', function(){ |
|
31
|
|
|
var obj1 = GedcomX.ExtensibleData(); |
|
32
|
|
|
var obj2 = GedcomX.ExtensibleData(obj1); |
|
33
|
|
|
assert.strictEqual(obj1, obj2); |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
}); |